package com.logic.idevice.impl.di

import com.logic.idevice.IUHFScan
import com.logic.idevice.impl.common.CommonScan
import com.logic.idevice.impl.dt51.DT51Scan
import com.logic.idevice.impl.kjd.KjdScan
import com.logic.idevice.impl.kv7.Kv7Scan
import com.sinopec.basemodule.constants.DeviceEnum
import kotlinx.coroutines.CoroutineScope

object ScanDi {

    /**
     * create by lwj at 2022/7/20
     * 根据不同类型的设备 去获取手持类
     */
    fun inject(
        callRefreshText: IUHFScan.IRefreshSpeed,
        callDataRefresh: IUHFScan.IRefreshData,
        callScanStatusChange: IUHFScan.IScanStatus,
        coroutineScope: CoroutineScope
    ): IUHFScan {
        return when (DeviceEnum.deviceType()) {
            DeviceEnum.COMMON -> {
                CommonScan(
                    callRefreshText,
                    callDataRefresh,
                    callScanStatusChange
                )
            }
            DeviceEnum.K71 -> {
                Kv7Scan(
                    callRefreshText,
                    callDataRefresh,
                    callScanStatusChange,
                    coroutineScope
                )
            }
            DeviceEnum.DT51 -> {
                DT51Scan(
                    callRefreshText,
                    callDataRefresh,
                    callScanStatusChange
                )
            }
            DeviceEnum.KJD -> {
                KjdScan(
                    callRefreshText,
                    callDataRefresh,
                    callScanStatusChange
                )
            }
            else -> {
                error("illegal device")
            }
        }
    }

}